<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="form.uname" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model.number="form.age" /><br /><br />

      <label>身高：</label>
      <input type="number" v-model.number="form.hight" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model.number="form.weight" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model="form.case" /><br /><br />

      <button @click.prevent="fn">诊断</button>
    </form>

    <p v-show="isShow">患者 的诊断结果: {{ good }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isShow: false,
      good: '',
      form: {
        uname: '',
        age: '',
        hight: '',
        weight: '',
        case: '',
      },
    }
  },
  methods: {
    fn() {
      let bmi = this.form.weight / (this.form.hight * this.form.hight)
      console.log(bmi)
      if (bmi > 23.9) {
        this.good = '体重过重'
      } else if (bmi < 18.5) {
        this.good = '体重过轻'
      } else {
        this.good = '健康'
      }
      this.isShow = true
    },
  },
}
</script>
